package com.smart.controller;


import com.smart.pojo.ResultBean;
import com.smart.pojo.RolePermission;
import com.smart.req.RolePermissionReq;
import com.smart.service.IRolePermissionService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lyj
 * @since 2023-04-19
 */
@RestController
@RequestMapping("/role-permission")
public class RolePermissionController {

    @Autowired
    private IRolePermissionService rolePermissionService;

    /**
     * 更新角色关联的权限
     */
    @PostMapping("authorizationByRoleId")
    @RequiresPermissions({"role:authoriaztion"})
    public ResultBean authorizationByRoleId(@RequestBody RolePermissionReq rolePermissionReq) {
        System.out.println("要更新的角色关联权限的信息：" + rolePermissionReq);

        boolean rs = rolePermissionService.authorizationByRoleId(rolePermissionReq);
        return rs ? ResultBean.success() : ResultBean.error();
    }
}
